<?php 
/**
 * @description : Module Video Search Filters
 * @class-name : ModuleVideoFilters()
 * @author : Aaron
 * @date : 2010-04-22
 */
class ModuleVideoFilters extends CmsModule {
    
    public function __init() {
		//$this->title = 'Filters';
		$this->id = 'video-filters';
		
		$modDateby = new CmsRadio();
		$modDateby->name = 'dateby';
		$modDateby->initTarget['custom_cssclass'] = 'dateby';  
		$modDateby->label = 'Show By';
		$modDateby->cols = 2;
		$modDateby->arr_options = AC::$dateby_list;
		$modDateby->bind = 'dateby';
		
		$modDatezone = new CmsDuration();
		$modDatezone->name = 'datezone';  
		$modDatezone->initTarget['custom_cssclass'] = 'datezone cms-form-item-hidden';  
		$modDatezone->nameType = 'array';
		$modDatezone->label = 'Date';
		$modDatezone->bind = 'start_end_day';

		$modTop = new CmsDropDown();
		$modTop->name = 'top_size';
		$modTop->label = 'Top';
		$modTop->arr_options = AC::$top_size;
		$modTop->bind = 'top_size';

        //category
		$modCategory = new CmsDropDown();
		$modCategory->multiple = true;
		$modCategory->name = 'category';
		//$modCategory->layout = 1;
		$modCategory->label = 'Video Category';
		$modCategory->arr_options = AC::getInstance()->getConfigSetting(AC::$category_list);
		$modCategory->bind = 'categorys';

        //subscription plan
		$modSubscriptionPlan = new CmsDropDown();
		//$modSubscriptionPlan->layout = 1;
		$modSubscriptionPlan->name = 'plan';
		$modSubscriptionPlan->label = 'Subscription Plan';
		$modSubscriptionPlan->arr_options = AC::$video_subscription_plan;
		$modSubscriptionPlan->bind = 'video_subscription_plan';
		
		$modPackagePlan = new CmsDropDown();
		$modPackagePlan->multiple = true;
		$modPackagePlan->name = 'package';
		//$modPackagePlan->initTarget['custom_cssclass'] = 'cms-form-item-hidden';
		$modPackagePlan->initTarget['custom_cssclass'] = 'cms-form-item-hidden';
		$modPackagePlan->label = 'Package Plan';
		$modPackagePlan->arr_options = AC::getInstance()->getConfigSetting(AC::$video_plan_package);
		$modPackagePlan->bind = 'video_plan_package';

		$modGender = new CmsDropDown();
		$modGender->name = 'gender';
		//$modGender->layout = 1;
		$modGender->label = 'Gender';
		$modGender->arr_options = AC::$gender_list;
		$modGender->bind = 'gender';

        //age group
		$modAge = new CmsDropDown();
		//$modAge->multiple = true;
		$modAge->name = 'age';
		$modAge->multiple = true;
		$modAge->label = 'Age Group';
		$modAge->arr_options = AC::getInstance()->getConfigSetting(AC::$age_list);
		$modAge->bind = 'age';
		
		/**
		$modCountry = new CmsCountrys();
		$modCountry->layout = 1;
		$modCountry->label = 'Region/Country'; 
		//$modCountry->bind = 'custom_country'; 
        */
        $modCountry = new CmsCountryList();
        $modCountry->name = 'countrys';   
        $modCountry->label = 'Region / Country';
        $modCountry->arr_options = AC::$country_stat;
        $modCountry->service = AC::$country_service;
        //$modCountry->bind = 'custom_country';
		

		$monthoptions = '';
		for($i=1;$i<13;$i++) {
            $i = ($i<10) ? '0'.$i : $i;
            $selected = ($i==date('m')) ? ' selected ' : null;
			$monthoptions .= "<option value='{$i}' {$selected}>{$i}</option>";
		}
		$yearoptions = '';
		for($i=2010;$i<date("Y")+10;$i++) {
            $selected = ($i==date('Y')) ? ' selected ' : null;
			$yearoptions .= "<option value='{$i}' {$selected} >{$i}</option>";
		}
		$modMonth = new CmsCustomFormItem();
		$modMonth->name = 'month';
		$modMonth->initTarget['custom_cssclass'] = 'bymonth';  
		$modMonth->label = 'Month';
		$modMonth->custom_block = '<select name="month" class="wauto">'.$monthoptions.'</select><select name="year" class="wauto">'.$yearoptions.'</select>';
		//$modMonth->bind = 'month';		
		
		$modSortby = new CmsDropDown();
		$modSortby->name = 'sort';
		$modSortby->layout = 1;
		$modSortby->label = 'Sort By';
		$modSortby->arr_options = AC::$frequency_duration_sortby;
		$modSortby->bind = 'frequency_duration_sortby';
		
		$separator_hidden = new CmsSeparator();
		
		$fieldset1 = new CmsFieldset();
		$fieldset1->title = 'Show By';
		$fieldset1->addAll(array($modDateby, $modMonth,$modDatezone,$modTop));
		
		$fieldset2 = new CmsFieldset();
		$fieldset2->title = 'Group By';
		$fieldset2->addAll(array($modCategory,$modSubscriptionPlan,$modPackagePlan,$separator_hidden,$modGender,$modAge,$modCountry));

		
		$fieldset3 = new CmsFieldset();
		$fieldset3->title = 'Sort By';
		$fieldset3->addAll(array($modSortby));
		
        $modbuttons = new CmsButton();
        $modbuttons->name = 'submit';
        $modbuttons->label = 'Submit';
        $modbuttons->type = 'button';
		
		$form = new CmsForm();
		$form->name = 'filter-form';
		$form->action='video_result.html';
		$form->addAll(array(
			$fieldset1,$fieldset2,$fieldset3,$modbuttons
		));
		
		$this->setBlock('main', $form);
    }
}
?>
